{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's define the Maven artifact for Weka's 3.9.3 developer version:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%maven nz.ac.waikato.cms.weka:weka-dev:3.9.3\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now let's cross-validate J48 on the UCI dataset *labor*:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Correctly Classified Instances          42               73.6842 %\n",
      "Incorrectly Classified Instances        15               26.3158 %\n",
      "Kappa statistic                          0.4415\n",
      "Mean absolute error                      0.3192\n",
      "Root mean squared error                  0.4669\n",
      "Relative absolute error                 69.7715 %\n",
      "Root relative squared error             97.7888 %\n",
      "Total Number of Instances               57     \n",
      "\n"
     ]
    }
   ],
   "source": [
    "import weka.classifiers.trees.J48;\n",
    "import weka.classifiers.Evaluation;\n",
    "import weka.core.converters.ConverterUtils.DataSource;\n",
    "import weka.core.Instances;\n",
    "import java.util.Random;\n",
    "\n",
    "Instances data = DataSource.read(\"https://svn.cms.waikato.ac.nz/svn/weka/trunk/wekadocs/data/labor.arff\");\n",
    "data.setClassIndex(data.numAttributes() - 1);\n",
    "\n",
    "J48 cls = new J48();\n",
    "Evaluation eval = new Evaluation(data);\n",
    "eval.crossValidateModel(cls, data, 10, new Random(1));\n",
    "System.out.println(eval.toSummaryString());"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Java",
   "language": "java",
   "name": "java"
  },
  "language_info": {
   "codemirror_mode": "java",
   "file_extension": ".java",
   "mimetype": "text/x-java-source",
   "name": "Java",
   "pygments_lexer": "java",
   "version": "11.0.2+9-LTS"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
